<?php
class Usuarios extends Controller {
	
	var $zona;
	var $upload_path;
	var $usr;
		
	function Usuarios(){
		parent::Controller(); 
		$this->load->library("rapyd");
		//$this->load->library("menues");
		//$this->datasis->modulo_id(901,1);		
		$this->zona=$this->datasis->traevalor('ZONA');
		$this->load->library("path");
		$path=new Path();
		$path->setPath($this->config->item('uploads_dir'));
		//$path->append('sgs/uploads/usuarios');
		$path->append('fotos/');
		$this->upload_path =$path->getPath().'/';
		//echo $this->upload_path;
	}
	function index(){
		redirect("supervisor/usuarios/filteredgrid");
	}	
	function filteredgrid(){
		$this->rapyd->load("datafilter","datagrid");
			
		$filter = new DataFilter("Buscar y Filtrar Usuarios","usuarios");
		$select=array("a.usu_status","a.usu_nom","a.usu_ape","a.usu_sex","a.usu_nac",
		"a.usu_ced","a.usu_dir","a.usu_tel","a.usu_cel","a.usu_correo","a.usu_cargo","IF(a.usu_tip='O','OPERADOR',IF(a.usu_tip='R','RESPONSABLE','TECNICO')) as usu_tip","a.usu_login","a.usu_contra",
		"b.zon_ide","b.zon_idm","b.zon_idp","CONCAT(b.zon_dese,'->',b.zon_desm,'->',b.zon_desp)as zona");		
		//$filter->db->select($select);
		//$filter->db->from('usuarios as a');
		//$filter->db->join('zonas  as b','a.zon_ide=b.zon_ide');
		//$filter->db->groupby('a.usu_login');
		
		$filter->usu_login = new inputField("Nombre de Usuario", "usu_login");
		$filter->usu_login->size=14;
		$filter->usu_login->maxlength=10;
			
		$filter->usu_ced = new inputField("C&eacute;dula/DNI", "usu_ced");
		$filter->usu_ced->size=14;
		$filter->usu_ced->maxlength=12;
		//$filter->usu_ced->append(' Formato: 12123123');

		$filter->usu_nom = new inputField("Nombre", "usu_nom");
		$filter->usu_nom->size=52;
		$filter->usu_nom->maxlength=50;
		
		$filter->usu_ape = new inputField("Apellido", "usu_ape");
		$filter->usu_ape->size=52;
		$filter->usu_ape->maxlength=50;
		
		$filter->usu_sex = new dropdownField("Sexo","usu_sex");
		$filter->usu_sex->option("","Todos");
		$filter->usu_sex->option("F","F");
		$filter->usu_sex->option("M","M");
		$filter->usu_sex->style ="width:90px";
		
		$filter->usu_tip = new dropdownField("Tipo de Usuario","usu_tip");
		$filter->usu_tip->option("","Todos");
		$filter->usu_tip->options("SELECT tusu_cod, tusu_desc FROM tusuarios");
									
		$filter->usu_status = new dropdownField("Estatus", "usu_status");
		$filter->usu_status->option("A","Activo");
		$filter->usu_status->option("I","Inactivo");
		$filter->usu_status->option("","Todos");
	                    	
		$filter->buttons("reset","search");
		$filter->build();
		
		$uri  = anchor('supervisor/usuarios/dataedit/show/<#usu_login#>','<#usu_login#>');
		$uri2 = anchor('supervisor/usuarios/cambioc/<#usu_login#>','Reasignar Contrase&ntilde;a');
		//$uri2 = anchor('supervisor/usuarios/enviarclave/<#usu_login#>','Enviar Clave');	
		$uri3 = anchor('supervisor/usuarios/accesos/<#usu_login#>/','Asignar');
		
		$grid = new DataGrid("");
		$grid->order_by("usu_login","asc");
		$grid->per_page = 10;
		
		$grid->column_ORDERBY("Usuario"      ,$uri       		,"usu_tip","align='left'NOWRAP");
		$grid->column_ORDERBY("C&eacute;dula"       ,"usu_ced"  		,"usu_ced","align='left'NOWRAP");
		$grid->column_ORDERBY("Nombre"       ,"usu_nom"  		,"usu_nom","align='left'NOWRAP");
		$grid->column_ORDERBY("Apellido"     ,"usu_ape"  		,"usu_ape ","align='left'NOWRAP");
		$grid->column("Tel&eacute;fono. Celular"         ,"usu_cel"  		,"usu_cel");
		$grid->column("Cargo"                ,"usu_cargo"		,"usu_carg");
		$grid->column("Tipo"                 ,"usu_tip"   	,"usu_tip");		
		$grid->column("Estatus"               ,"usu_status"  ,'align="center"');
		$grid->column("Correo-e"             ,"usu_correo"  ,'align="left"');
		//$grid->column("Olvido Contrase&ntilde;a"    ,$uri2       	,'align="center"');
		//$grid->column("Accesos"              ,$uri3       ,'align="center"');
		
		$grid->add("supervisor/usuarios/dataedit/create");
		$grid->build();
		//echo $grid->db->last_query();
				      
		$data['filtro']  = $filter->output;
		$data['content'] = $grid->output;
		$data['title']   = heading("Usuarios del Sistema");
		$data["head"]    = script("jquery.pack.js").script("plugins/jquery.numeric.pack.js").script("plugins/jquery.floatnumber.js").$this->rapyd->get_head();
		$this->load->view('view_ventanas', $data); 
	}
	function dataedit(){ 
		$this->rapyd->load("dataedit");
				
		$edit = new DataEdit(" ", "usuarios");
		$edit->back_url = site_url("supervisor/usuarios/filteredgrid");
		
		$script ='
		$(function() {
			$(".inputnum").numeric(".");
		});
		';
		
		//$edit->post_process('insert','_pos_insert');
		//$edit->post_process('update','_pos_update');
		//$edit->post_process('delete','_pos_delete');
		$edit->script($script, "create");
		$edit->script($script, "modify");
				
		if($edit->_status=='show'){
			$usu_foto  =$edit->_dataobject->get("usu_foto");
			if(!empty($usu_foto)){
				$edit->fotover = new iframeField("related", "supervisor/usuarios/verfoto/$usu_foto","170");
			}else{
				$edit->fotover = new iframeField("related", "supervisor/usuarios/verfoto","1");	
			}
		};
		
		$edit->usu_nac = new dropdownField("C&eacute;dula/DNI","usu_nac");
		$edit->usu_nac->rule = "required";
		$edit->usu_nac->option("V","V");
		$edit->usu_nac->option("E","E"); 
		$edit->usu_nac->group="Datos Personales";
		$edit->usu_nac->style='width:50px;';
						
		$edit->usu_ced = new inputField("", "usu_ced");
		$edit->usu_ced->rule = "required|callback_chexistecedula";
		$edit->usu_ced->size = 12; 
		$edit->usu_ced->maxlength = 8;
		$edit->usu_ced->append(' Formato: 12123123');
		$edit->usu_ced->group="Datos Personales";
		$edit->usu_ced->css_class='inputnum';	
		$edit->usu_ced->mode = "autohide";
		$edit->usu_ced->in="usu_nac";
							
		$edit->usu_ape = new inputField("Apellido", "usu_ape");
		$edit->usu_ape->rule = "strtoupper|required";
		$edit->usu_ape->size = 52; 
		$edit->usu_ape->maxlength = 50;
		$edit->usu_ape->group="Datos Personales";
		
		$edit->usu_nom = new inputField("Nombre", "usu_nom");
		$edit->usu_nom->rule = "strtoupper|required";
		$edit->usu_nom->size = 52; 
		$edit->usu_nom->maxlength = 50;
		$edit->usu_nom->group="Datos Personales";
				
		$edit->usu_sex = new dropdownField("Sexo","usu_sex");
		$edit->usu_sex->option("F","Femenino");
		$edit->usu_sex->option("M","Masculino");
		$edit->usu_sex->group="Datos Personales";
		$edit->usu_sex->style = "width:120px";
		
		$edit->usu_nacimi = new dateonlyField("Fecha de Nacimiento","usu_nacimi");
		$edit->usu_nacimi->insertValue = date("d/m/Y");	
		$edit->usu_nacimi->group="Datos Personales";
		$edit->usu_nacimi->size = 12;     
		
		$edit->usu_dir = new textareaField("Direcci&oacute;n de Habitaci&oacute;n", "usu_dir");
		$edit->usu_dir->rule = "required|strtoupper";
		$edit->usu_dir->cols = 80;
		$edit->usu_dir->rows =3;
		$edit->usu_dir->group="Informaci&oacute;n de Ubicaci&oacute;n";
		
		$edit->usu_tel = new inputField("Tel&eacute;fono Local", "usu_tel");
		$edit->usu_tel->size = 22; 
		$edit->usu_tel->maxlength = 11;
		$edit->usu_tel->css_class='inputnum';	
		$edit->usu_tel->append(' Formato: 02748810000');
		$edit->usu_tel->group="Informaci&oacute;n de Ubicaci&oacute;n";
  
		$edit->usu_cel = new inputField("Tel&eacute;fono Movil", "usu_cel");
		$edit->usu_cel->size = 22; 
		$edit->usu_cel->maxlength = 11;
		$edit->usu_cel->css_class='inputnum';
		$edit->usu_cel->rule = "required";
		$edit->usu_cel->append(' Formato: 04268810000');
		$edit->usu_cel->group="Informaci&oacute;n de Ubicaci&oacute;n";
		
		$edit->usu_correo = new inputField("Correo-e Corporativo", "usu_correo");
		$edit->usu_correo->size = 52; 
		$edit->usu_correo->maxlength = 50;
		$edit->usu_correo->group="Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->usu_correo->rule = "required";
		$edit->usu_correo->append(' Formato: micuenta@fycotelecom.com');
		$edit->usu_correo->rule = "valid_email";
		
		$edit->email  = new inputField("Correo-e Personal", "usu_email");
		$edit->email->rule = "required|trim";
		$edit->email->size =50;
		$edit->email->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->email->maxlength =40;
		
		$edit->msn = new inputField("Messenger","usu_msn");
		$edit->msn->rule = "trim";
		$edit->msn->size=50;
		$edit->msn->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->msn->maxlength =40;
		
		$edit->skype = new inputField("Skype","usu_skype");
		$edit->skype->rule = "trim";
		$edit->skype->size=50;
		$edit->skype->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->skype->maxlength =20;
		
		$edit->bbpin = new inputField("BB Pin","usu_bbpin");
		$edit->bbpin->rule = "trim|strtoupper";
		$edit->bbpin->size=20;
		$edit->bbpin->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->bbpin->maxlength =10;
					
		//$edit->zon_ide = new dropdownField("Estado", "zon_ide"); 
		//$edit->zon_ide->option("","Seleccione un Estado");                               
		//$edit->zon_ide->options("SELECT zon_ide, zon_dese FROM zonas ORDER BY zon_dese");
		//$edit->zon_ide->onchange = "get_zonidm();";
		//$edit->zon_ide->rule = "required"; 
		//$edit->zon_ide->group="Zona Geogr&aacute;fica";
		//
		//$edit->zon_idm = new dropdownField("Municipio", "zon_idm"); 
		//$edit->zon_idm->option("","Seleccione un Municipio");                               
		//$edit->zon_idm->options("SELECT zon_idm, zon_desm FROM zonas ORDER BY zon_desm");
		//$edit->zon_idm->onchange = "get_zonidp();";
		//$edit->zon_idm->rule = "required";
		//$edit->zon_idm->group="Zona Geogr&aacute;fica"; 
		//		
		//$edit->zon_idp = new dropdownField("Parroquia", "zon_idp"); 
		//$edit->zon_idp->option("","Seleccione una Parroquia");
		//$edit->zon_idp->onchange = "get_zonids();";
		////$edit->zon_idp->rule = "required";                               
		//$edit->zon_idp->options("SELECT zon_idp, zon_desp FROM zonas ORDER BY zon_desp");
		//$edit->zon_idp->group="Zona Geogr&aacute;fica";
			        		     
		$edit->usu_login = new inputField("Nombre de Usuario","usu_login");
		$edit->usu_login->rule = "required|callback_chexiste";
		$edit->usu_login->size = 12;
		$edit->usu_login->maxlength  = 10;
		$edit->usu_login->mode = "autohide";
		$edit->usu_login->group="Informaci&oacute;n de Usuario";
		
		$edit->usu_contra = new inputField("Contrase&ntilde;a","usu_contra");
		$edit->usu_contra->type= "password";
		$edit->usu_contra->size = 12;
		$edit->usu_contra->maxlength = 10;
		//$edit->usu_contra->when = array("create","show");
		$edit->usu_contra->mode = "autohide";
		$edit->usu_contra->group="Informaci&oacute;n de Usuario";
		$edit->usu_contra->rule ="required";
		//$edit->usu_contra->minlength = 6;
		//$edit->usu_contra->maxlength = 15;
		//$edit->usu_contra->append(' Minino 6 Cararteres y M&aacute;ximo 15 Cararteres');

		$edit->usu_pre = new inputField("Palabra Secreta", "usu_pre");
		$edit->usu_pre->rule = "strtoupper|required";
		$edit->usu_pre->size = 52; 
		$edit->usu_pre->maxlength = 50;
		$edit->usu_pre->group="Informaci&oacute;n de Usuario";
		$edit->usu_pre->append(' Se utiliza para recuperar su contra&ntilde;a');
				
		//$edit->usu_contra2 = new inputField("Confirmacion","usu_contra2");
		//$edit->usu_contra2->rule = "required";
		//$edit->usu_contra2->type= "password";
		//$edit->usu_contra2->size = 12;
		//$edit->usu_contra2->maxlength = 10;
		//$edit->usu_contra2->when = array("create");
		//$edit->usu_contra2->group="Informaci&oacute;n de Usuario";	
		
		$edit->usu_fec = new dateonlyField("Fecha de Creaci&oacute;n", "usu_fec");
		$edit->usu_fec->insertValue = date("d/m/Y");	
		$edit->usu_fec->group="Informaci&oacute;n de Usuario";
		$edit->usu_fec->when = array("show");
		
		$edit->usu_super = new dropdownField("Supervisor","usu_super");
		$edit->usu_super->option("N","N");
		$edit->usu_super->option("S","S");
		$edit->usu_super->style = "width:100px";
		$edit->usu_super->group="Informaci&oacute;n de Usuario";
		
		$edit->usu_tip = new dropdownField("Tipo de Usuario","usu_tip");
		$edit->usu_tip->options("SELECT tusu_cod, tusu_desc FROM tusuarios");
		$edit->usu_tip->group="Informaci&oacute;n de Usuario";
		
		$edit->usu_status = new dropdownField("Status", "usu_status");
		$edit->usu_status->option("A","Activo");
		$edit->usu_status->option("I","Inactivo");
		$edit->usu_status->style = "width:100px"; 
		$edit->usu_status->group="Informaci&oacute;n de Usuario";
		
		$edit->usu_foto = new uploadField("Fotografia", "usu_foto");
		$edit->usu_foto->upload_path   =$this->upload_path;                  
		$edit->usu_foto->delete_file   =false;
		$edit->usu_foto->allowed_types = "jpg|gif|swf|png";
		$edit->usu_foto->group = "Informaci&oacute;n de Usuario";	
		
		$edit->usu_cargo = new inputField("Cargo", "usu_cargo");
		$edit->usu_cargo->rule = "strtoupper";
		$edit->usu_cargo->size = 52; 
		$edit->usu_cargo->maxlength = 50;
		$edit->usu_cargo->group = "Informaci&oacute;n de Usuario";
				
		$edit->buttons("modify", "save", "undo", "back","delete");
		$edit->build();
		
		$link=site_url('supervisor/usuarios/get_zonidm');
		$link2=site_url('supervisor/usuarios/get_zonidp');
		$link3=site_url('supervisor/usuarios/get_zonids');

		$data['script']  =<<<script
		<script type="text/javascript" charset="utf-8">
		function get_zonidm(){
			var zonide=$("#zon_ide").val();
			$.ajax({
				url: "$link"+'/'+zonide,
				success: function(msg){
					$("#td_zon_idm").html(msg);
				//alert(zonide); 
				}
			});			
		}
		function get_zonidp(){
			var zonidm=$("#zon_idm").val();
			$.ajax({
				url: "$link2"+'/'+zonidm,
				success: function(msg){
					$("#td_zon_idp").html(msg);
					//alert(zonidm);
				}
			});
		}
		function get_zonids(){
			var zonidp=$("#zon_idp").val();
			$.ajax({
				url: "$link3"+'/'+zonidp,
				success: function(msg){
					$("#td_zon_ids").html(msg);
					//alert(zonidp);
				}
			});
		}		
		
		</script>
script;
		//$smenu['link']=barra_menu('901');
		//$data['smenu']   = $this->load->view('view_sub_menu', $smenu,true);		
		$data['content'] =$edit->output;        
		$data['title'] = heading('('.$edit->usu_login->value.') '.$edit->usu_nom->value.' '.$edit->usu_ape->value);
		$data["head"]    = script("jquery.pack.js").script("plugins/jquery.numeric.pack.js").script("plugins/jquery.floatnumber.js").$this->rapyd->get_head();
		$this->load->view('view_ventanas', $data); 
	}
	function get_zonidm($zon_ide=null){
		$this->rapyd->load("fields");
		
		$zon_idm = new dropdownField("Estado","zon_idm");
		$zon_idm->option("","Seleccione un Municipio");
		$zon_idm->status = "modify";
		$zon_idm->onchange = "get_zonidp();";
		$zon_idm->options("SELECT zon_idm, zon_desm FROM zonas  WHERE zon_ide='$zon_ide' ORDER BY zon_idm");
		//$usu_dep->style="width:350px";
		$zon_idm->build();		
		echo $zon_idm->output;
	}
	function get_zonidp($zon_idm=null){
		$this->rapyd->load("fields");
		
		$zon_idp = new dropdownField("Municipio","zon_idp");
		$zon_idp->option("","Seleccione una Parroquia");
		$zon_idp->status = "modify";
		$zon_idp->onchange = "get_zonids();";
		$zon_idp->options("SELECT zon_idp, zon_desp FROM zonas  WHERE zon_idm='$zon_idm' ORDER BY zon_idp");
		//$usu_dep->style="width:350px";
		$zon_idp->build();		
		echo $zon_idp->output;
	}
	function yo(){
		$usr=$this->session->userdata['usuario'];
		redirect("supervisor/usuarios/miusuario/show/$usr");		
	}
	function miusuario($usr){
		$this->rapyd->load("dataedit");
		
		$script ='
		$(function() {
			$(".inputnum").numeric(".");
		});
		';
				
		$edit = new DataEdit(" ", "usuarios");
				
		//$edit->post_process('insert','_pos_insert');
		//$edit->post_process('update','_pos_update');
		//$edit->post_process('delete','_pos_delete');
		$edit->script($script, "create");
		$edit->script($script, "modify");
		
		if($edit->_status=='show'){
			$usu_foto  =$edit->_dataobject->get("usu_foto");	
			if(!empty($usu_foto)){
				$edit->fotover = new iframeField("related", "supervisor/usuarios/verfoto/$usu_foto","170");
			}else{
				$edit->fotover = new iframeField("related", "supervisor/usuarios/verfoto","1");	
			}
		};
						
		$edit->usu_nac = new dropdownField("C&eacute;dula","usu_nac");
		$edit->usu_nac->rule = "required";
		$edit->usu_nac->option("V","V");
		$edit->usu_nac->option("E","E"); 
		$edit->usu_nac->group="Datos Personales";
		$edit->usu_nac->style='width:50px;';
						
		$edit->usu_ced = new inputField("", "usu_ced");
		$edit->usu_ced->rule = "required";
		$edit->usu_ced->size = 12; 
		$edit->usu_ced->maxlength = 8;
		$edit->usu_ced->append(' Formato: 12123123');
		$edit->usu_ced->group="Datos Personales";
		$edit->usu_ced->css_class='inputnum';	
		$edit->usu_ced->in="usu_nac"; 
					
		$edit->usu_ape = new inputField("Apellido", "usu_ape");
		$edit->usu_ape->rule = "strtoupper|required";
		$edit->usu_ape->size = 52; 
		$edit->usu_ape->maxlength = 50;
		$edit->usu_ape->group="Datos Personales";
		
		$edit->usu_nom = new inputField("Nombre", "usu_nom");
		$edit->usu_nom->rule = "strtoupper|required";
		$edit->usu_nom->size = 52; 
		$edit->usu_nom->maxlength = 50;
		$edit->usu_nom->group="Datos Personales";	
				
		$edit->usu_sex = new dropdownField("Sexo","usu_sex");
		$edit->usu_sex->option("F","Femenino");
		$edit->usu_sex->option("M","Masculino");
		$edit->usu_sex->group="Datos Personales";
						
		$edit->usu_dir = new textareaField("Direcci&oacute;n de Habitacion", "usu_dir");
		$edit->usu_dir->rule = "strtoupper";
		$edit->usu_dir->cols = 80;
		$edit->usu_dir->rows =3;
		$edit->usu_dir->group="Informaci&oacute;n de Ubicaci&oacute;n";
					
		$edit->usu_tel = new inputField("Tel&eacute;fono Local", "usu_tel");
		$edit->usu_tel->size = 22; 
		$edit->usu_tel->maxlength = 11;
		$edit->usu_tel->css_class='inputnum';	
		$edit->usu_tel->append(' Formato: 02748810000');
		$edit->usu_tel->group="Informaci&oacute;n de Ubicaci&oacute;n";
  
		$edit->usu_cel = new inputField("Tel&eacute;fono Movil", "usu_cel");
		$edit->usu_cel->size = 22; 
		$edit->usu_cel->maxlength = 11;
		$edit->usu_cel->css_class='inputnum';		
		$edit->usu_cel->append(' Formato: 04268810000');
		$edit->usu_cel->group="Informaci&oacute;n de Ubicaci&oacute;n";
		
		$edit->usu_correo = new inputField("Correo-e Corporativo", "usu_correo");
		$edit->usu_correo->size = 52; 
		$edit->usu_correo->maxlength = 50;
		$edit->usu_correo->group="Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->usu_correo->rule = "required";
		$edit->usu_correo->append(' Formato: micuenta@fycotelecom.com');
		$edit->usu_correo->rule = "valid_email";
		
		$edit->email  = new inputField("Correo-e Personal", "usu_email");
		$edit->email->rule = "trim";
		$edit->email->size =50;
		$edit->email->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->email->maxlength =40;
		
		$edit->msn = new inputField("Messenger","usu_msn");
		$edit->msn->rule = "trim";
		$edit->msn->size=50;
		$edit->msn->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->msn->maxlength =40;
		
		$edit->skype = new inputField("Skype","usu_skype");
		$edit->skype->rule = "trim";
		$edit->skype->size=50;
		$edit->skype->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->skype->maxlength =20;
		
		$edit->bbpin = new inputField("BB Pin","usu_bbpin");
		$edit->bbpin->rule = "trim|strtoupper";
		$edit->bbpin->size=20;
		$edit->bbpin->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->bbpin->maxlength =10;
		
		$edit->usu_cargo = new inputField("Cargo", "usu_cargo");
		$edit->usu_cargo->rule = "strtoupper";
		$edit->usu_cargo->size = 52; 
		$edit->usu_cargo->maxlength = 50;
		$edit->usu_cargo->group = "Informaci&oacute;n de Usuario";
		
		$edit->usu_pre = new inputField("Palabra Secreta", "usu_pre");
		$edit->usu_pre->rule = "strtoupper|required";
		$edit->usu_pre->size = 52; 
		$edit->usu_pre->maxlength = 50;
		$edit->usu_pre->group="Informaci&oacute;n de Usuario";
		$edit->usu_pre->append(' Se utiliza para recuperar su contrase&ntilde;a');
		
		$edit->usu_foto = new uploadField("Fotografia", "usu_foto");
		$edit->usu_foto->upload_path   =$this->upload_path;                  
		$edit->usu_foto->delete_file   =false;
		$edit->usu_foto->allowed_types = "jpg|gif|swf|png|bmp";
		$edit->usu_foto->group = "Informaci&oacute;n de Usuario";
									     								
		$edit->buttons("modify", "save", "undo");
		$edit->build();
				
		$CI =& get_instance();
		$usu=$CI->session->userdata('usuario');
		
		$data['content'] =$edit->output;
		$data['filtro']  = '';
		$data['title'] = heading("Mis Datos de Usuario: $usu");
		$data["head"]    = script("jquery.pack.js").script("plugins/jquery.numeric.pack.js").script("plugins/jquery.floatnumber.js").$this->rapyd->get_head();
		$this->load->view('view_ventanas', $data); 
	}
	function verfoto($usu_foto=''){		
		Echo $ver = "<img src='".$this->upload_path."$usu_foto'  width=150  height=150 border=1 align='right' >";		
	}
	function olvido(){
		
		$this->rapyd->load("datafilter","datagrid");
			
		$script ='
		$(function() {
			$(".inputnum").numeric(".");
		});
		';
		
		$base_process_uri= $this->rapyd->uri->implode_uri("base_uri","gfid","orderby");
		$filter = new DataForm($this->rapyd->uri->add_clause($base_process_uri, "search"));
		$filter->attributes=array('onsubmit'=>'is_loaded()');
		$filter->title("Ingrese los datos solicitados");
		$filter->script($script, "create");
		$filter->script($script, "modify");
					
		$filter->usu_ced = new inputField("C&eacute;dula/DNI", "a.usu_ced");
		$filter->usu_ced->size=14;
		$filter->usu_ced->maxlength=12;
		$filter->usu_ced->rule = "required";
		$filter->usu_ced->clause="where";
		$filter->usu_ced->operator="=";
		$filter->usu_ced->css_class='inputnum';
		//$filter->usu_ced->append(' Formato:10123456');
			
		$filter->usu_pre = new inputField("Palabra Secreta", "a.usu_pre");
		$filter->usu_pre->size=30;
		$filter->usu_pre->maxlength=50;
		$filter->usu_pre->clause="where";
		$filter->usu_pre->operator="="; 
		$filter->usu_pre->rule = "required";
		$filter->usu_pre->append(' Palabra Secreta de Recuperaci&oacute;n');
		
		$filter->submit("btnsubmit","Recuperar Contrase&ntilde;a");
		$filter->build_form();
		
		$table='';
		
		if($this->rapyd->uri->is_set("search") AND $filter->is_valid()){
			
			$usu_ced=$filter->usu_ced->newValue;
			$usu_pre=$filter->usu_pre->newValue;
			
			$grid = new DataGrid("");
			$select=array("a.usu_login","a.usu_pre","a.usu_nom","a.usu_ape","a.usu_ced","a.usu_contra");		
			$grid->db->select($select);
			$grid->db->from('usuarios as a');
			$grid->db->where('a.usu_ced',$usu_ced);
			$grid->db->where('a.usu_pre',$usu_pre);
			$grid->per_page = 10;
			
			$uri = anchor('supervisor/usuarios/cambioc/<#usu_login#>','Cambiar Contrase&ntilde;a');
			
			$grid->column("Usuario"      ,"usu_login"  	,"align='center'");
			$grid->column("Clave"        ,"usu_contra"  ,"align='center'");
			$grid->column("Nombre"       ,"usu_nom"  		,"align='left'");
			$grid->column("Apellido"     ,"usu_ape"  		,"align='left'");
							
			//$grid->add("supervisor/usuarios/dataedit/create");
    	
			$table=$grid->build();
		  //echo $grid->db->last_query();
			$SQL=$grid->db->last_query();
			$mSQL_1=$this->db->query($SQL);
			$row = $mSQL_1->row();
			
			IF($mSQL_1->num_rows()>0){
				$table=$grid->output;	
	  	}else{
	  		$table='<h5><b style="color:red;">No existen registros con los datos seleccionados</b></h5>';
	  	}
	  }
	  
	    $iniciar = anchor('bienvenido','Iniciar Sesi&oacute;n');		      
		
		$data['filtro']  = $filter->output;
		$data['content'] = $table;
		$data['title']  = heading("Recuperar Contrase&ntilde;a  $iniciar");        
		$data['resub']   = "Datos del Usuario";
		$data["head"]    = script("jquery.pack.js").script("plugins/jquery.numeric.pack.js").script("plugins/jquery.floatnumber.js").$this->rapyd->get_head();
		$this->load->view('view_ventanas_sola', $data);
	}
	function cambioc($usu_login=''){
	 	
		$this->rapyd->load("datafilter","datagrid");
		
		if(empty($usu_login)){
			$this->usr=$this->session->userdata['usuario'];
		}else{
			$this->usr=$usu_login;
		}
			
		//Echo $this->usr;
			
		$filter = new DataFilter("Ingrese su Contrase&ntilde;a");
			
		$filter->usu_contra = new inputField("Contrase&ntilde;a", "a.usu_contra");
		$filter->usu_contra->size=14;
		$filter->usu_contra->maxlength=12;
		$filter->usu_contra->rule = "required";
		$filter->usu_contra->clause="where";
		$filter->usu_contra->operator="="; 
					
		$filter->buttons("reset","search");
		$filter->build();
		
		$tabla='';
		
		if($this->rapyd->uri->is_set("search") AND $filter->is_valid()){
			
			$this->usr=$this->session->userdata['usuario'];
			$usu_contra=$filter->usu_contra->newValue;
			
			$uri  = anchor('supervisor/usuarios/cambiarc/modify/<#usu_login#>','Realizar Cambio');
		
			$grid = new DataGrid("");
			$select=array("a.usu_login","a.usu_pre","a.usu_nom","a.usu_ape","a.usu_ced","a.usu_contra");		
			$grid->db->select($select);
			$grid->db->from('usuarios as a');
			$grid->db->where('a.usu_login ',$this->usr);
			$grid->per_page = 10;
			
			$grid->column("Usuario"      ,"usu_login"  	,"align='center'");
			$grid->column("Contrase&ntilde;a"   ,$uri  ,"align='center'");
			$grid->column("Cedula"       ,"usu_ced"  		,"align='left'");
			$grid->column("Nombre"       ,"usu_nom"  		,"align='left'");
			$grid->column("Apellido"     ,"usu_ape"  		,"align='left'");
			//$grid->column("Contrase&ntilde;a"   ,"usu_contra"  ,"align='center'");
			
			//$grid->add("supervisor/usuarios/dataedit/create");
    	
			$table=$grid->build();
			//echo $grid->db->last_query();
		  
			$SQL=$grid->db->last_query();
			$mSQL_1=$this->db->query($SQL);
			$row = $mSQL_1->row();
			
			
			IF($mSQL_1->num_rows()>0){
			$tabla=$grid->output;	
	  	}else{
	  		$tabla='<h5><b style="color:red;">No existen registros con los datos seleccionados</b></h5>';
	  	}
		}
			      
		//$data['filtro']  = '';
		$data['content'] = $filter->output.$tabla;
		$data['filtro']  = '';
		$data['title'] = heading("Cambiar Contrase&ntilde;a");
		$data["head"]    = script("jquery.pack.js").script("plugins/jquery.numeric.pack.js").script("plugins/jquery.floatnumber.js").$this->rapyd->get_head();
		$this->load->view('view_ventanas',$data);
	}
	function cambiarc(){ 
		$this->rapyd->load("dataedit");
				
		$edit = new DataEdit("Ingrese su nueva contrase&ntilde;a", "usuarios");
		$edit->back_url = site_url("supervisor/usuarios/cambioc");
				
		$edit->usu_contra = new inputField("Contrase&ntilde;a","usu_contra");
		$edit->usu_contra->rule = "required";
		$edit->usu_contra->type= "password";
		$edit->usu_contra->size = 12;
		$edit->usu_contra->maxlength = 10;
		
		$edit->buttons("modify", "save", "undo","back");
		$edit->build();
		
		$data['content'] =$edit->output;        
		$data['filtro']  = '';
		$data['title'] = heading("Cambiar Contrase&ntilde;a");
		$data["head"]    = script("jquery.pack.js").script("plugins/jquery.numeric.pack.js").script("plugins/jquery.floatnumber.js").$this->rapyd->get_head();
		$this->load->view('view_ventanas', $data); 
	}
    function clientes(){
        
        $this->rapyd->load("dataedit");
				
		$edit = new DataEdit("Registro de Usuario", "usuarios");
		$edit->back_url = site_url("supervisor/usuarios/filteredgrid");
		
		$script ='
		$(function() {
			$(".inputnum").numeric(".");
		});
		';
		
		$edit->post_process('update','_pos_insert2');
		//$edit->post_process('update','_pos_update');
		//$edit->post_process('delete','_pos_delete');
		$edit->script($script, "create");
		$edit->script($script, "modify");
				
		$pais=$this->datasis->traevalor('PAIS');
        
        $edit->usu_nac = new dropdownField("N&deg; Identificaci&oacute;n Personal","usu_nac");
		$edit->usu_nac->rule = "required";
		$edit->usu_nac->option("V","$pais");
		$edit->usu_nac->option("E","Exterior"); 
		$edit->usu_nac->group="Datos Personales";
		$edit->usu_nac->style='width:160px;';
						
		$edit->usu_ced = new inputField("", "usu_ced");
		$edit->usu_ced->rule = "required";
		$edit->usu_ced->size = 12; 
		$edit->usu_ced->maxlength = 12;
		//$edit->usu_ced->append(' Formato: 12123123');
		$edit->usu_ced->group="Datos Personales";
		//$edit->usu_ced->css_class='inputnum';	
		//$edit->usu_ced->mode = "autohide";
		$edit->usu_ced->in="usu_nac";
							
		$edit->usu_ape = new inputField("Apellidos", "usu_ape");
		$edit->usu_ape->rule = "strtoupper|required";
		$edit->usu_ape->size = 52; 
		$edit->usu_ape->maxlength = 50;
		$edit->usu_ape->group="Datos Personales";
		
		$edit->usu_nom = new inputField("Nombres", "usu_nom");
		$edit->usu_nom->rule = "strtoupper|required";
		$edit->usu_nom->size = 52; 
		$edit->usu_nom->maxlength = 50;
		$edit->usu_nom->group="Datos Personales";
				
		$edit->usu_sex = new dropdownField("Sexo","usu_sex");
		$edit->usu_sex->option("F","Femenino");
		$edit->usu_sex->option("M","Masculino");
		$edit->usu_sex->group="Datos Personales";
		$edit->usu_sex->style = "width:120px";
		
		$edit->usu_nacimi = new dateonlyField("Fecha de Nacimiento","usu_nacimi");
		$edit->usu_nacimi->insertValue = date("d/m/Y");	
		$edit->usu_nacimi->group="Datos Personales";
		$edit->usu_nacimi->size = 12;
        
        $edit->usu_rif = new inputField("N&deg; Identificaci&oacute;n de la Empresa", "usu_rif");
		$edit->usu_rif->size = 20; 
		$edit->usu_rif->maxlength = 20;
		$edit->usu_rif->group="Informaci&oacute;n de Ubicaci&oacute;n";   
        
        $edit->usu_empresa = new inputField("Nombre de la Empresa", "usu_empresa");
		$edit->usu_empresa->size = 60; 
		$edit->usu_empresa->maxlength = 100;
		$edit->usu_empresa->group="Informaci&oacute;n de Ubicaci&oacute;n";     
		
		$edit->usu_dir = new textareaField("Direcci&oacute;n", "usu_dir");
		$edit->usu_dir->rule = "required|strtoupper";
		$edit->usu_dir->cols = 80;
		$edit->usu_dir->rows =3;
		$edit->usu_dir->group="Informaci&oacute;n de Ubicaci&oacute;n";
        
        $edit->usu_cargo = new inputField("Su Cargo dentro de la Empresa", "usu_cargo");
		$edit->usu_cargo->rule = "strtoupper";
		$edit->usu_cargo->size = 52; 
		$edit->usu_cargo->maxlength = 50;
		$edit->usu_cargo->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		
		$edit->usu_tel = new inputField("Tel&eacute;fono Local", "usu_tel");
		$edit->usu_tel->size = 22; 
		$edit->usu_tel->maxlength = 20;
		$edit->usu_tel->css_class='inputnum';	
		//$edit->usu_tel->append(' Formato: 02748810000');
		$edit->usu_tel->group="Informaci&oacute;n de Ubicaci&oacute;n";
  
		$edit->usu_cel = new inputField("Tel&eacute;fono Movil", "usu_cel");
		$edit->usu_cel->size = 22; 
		$edit->usu_cel->maxlength = 20;
		$edit->usu_cel->css_class='inputnum';
		$edit->usu_cel->rule = "required";
		//$edit->usu_cel->append(' Formato: 04268810000');
		$edit->usu_cel->group="Informaci&oacute;n de Ubicaci&oacute;n";
		
		$edit->usu_correo = new inputField("Correo-e Corporativo", "usu_correo");
		$edit->usu_correo->size = 52; 
		$edit->usu_correo->maxlength = 50;
		$edit->usu_correo->group="Informaci&oacute;n de Ubicaci&oacute;n";
		//$edit->usu_correo->rule = "required";
		$edit->usu_correo->append(' Formato: micuenta@miempresa.com');
		$edit->usu_correo->rule = "valid_email";
		
		$edit->email  = new inputField("Correo-e Personal", "usu_email");
		$edit->email->rule = "required|trim";
		$edit->email->size =50;
		$edit->email->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->email->maxlength =40;
		
		$edit->msn = new inputField("Messenger","usu_msn");
		$edit->msn->rule = "trim";
		$edit->msn->size=50;
		$edit->msn->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->msn->maxlength =40;
		
		$edit->skype = new inputField("Skype","usu_skype");
		$edit->skype->rule = "trim";
		$edit->skype->size=50;
		$edit->skype->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->skype->maxlength =20;
		
		$edit->bbpin = new inputField("BB Pin","usu_bbpin");
		$edit->bbpin->rule = "trim|strtoupper";
		$edit->bbpin->size=20;
		$edit->bbpin->group = "Informaci&oacute;n de Ubicaci&oacute;n";
		$edit->bbpin->maxlength =10;
					
		$edit->zon_ide = new dropdownField("Estado", "zon_ide"); 
		$edit->zon_ide->option("","Seleccione un Estado");                               
		$edit->zon_ide->options("SELECT zon_ide, zon_dese FROM zonas ORDER BY zon_dese");
		$edit->zon_ide->onchange = "get_zonidm();";
		//$edit->zon_ide->rule = "required"; 
		$edit->zon_ide->group="Zona Geogr&aacute;fica";
		
		$edit->zon_idm = new dropdownField("Municipio", "zon_idm"); 
		$edit->zon_idm->option("","Seleccione un Municipio");                               
		$edit->zon_idm->options("SELECT zon_idm, zon_desm FROM zonas ORDER BY zon_desm");
		$edit->zon_idm->onchange = "get_zonidp();";
		//$edit->zon_idm->rule = "required";
		$edit->zon_idm->group="Zona Geogr&aacute;fica"; 
				
		$edit->zon_idp = new dropdownField("Parroquia", "zon_idp"); 
		$edit->zon_idp->option("","Seleccione una Parroquia");
		$edit->zon_idp->onchange = "get_zonids();";
		//$edit->zon_idp->rule = "required";                               
		$edit->zon_idp->options("SELECT zon_idp, zon_desp FROM zonas ORDER BY zon_desp");
		$edit->zon_idp->group="Zona Geogr&aacute;fica";
			        		     
		$edit->usu_login = new inputField("Nombre de Usuario","usu_login");
		$edit->usu_login->rule = "required|callback_chexiste";
		$edit->usu_login->size = 12;
		$edit->usu_login->maxlength  = 10;
		$edit->usu_login->mode = "autohide";
		$edit->usu_login->group="Informaci&oacute;n de Usuario";
		
		$edit->usu_contra = new inputField("Contrase&ntilde;a","usu_contra");
		$edit->usu_contra->type= "password";
		$edit->usu_contra->size = 12;
		$edit->usu_contra->maxlength = 10;
		//$edit->usu_contra->when = array("create","show");
		$edit->usu_contra->mode = "autohide";
		$edit->usu_contra->group="Informaci&oacute;n de Usuario";
		$edit->usu_contra->rule ="required";
		//$edit->usu_contra->minlength = 6;
		//$edit->usu_contra->maxlength = 15;
		//$edit->usu_contra->append(' Minino 6 Cararteres y M&aacute;ximo 15 Cararteres');

		$edit->usu_pre = new inputField("Palabra Secreta", "usu_pre");
		$edit->usu_pre->rule = "strtoupper|required";
		$edit->usu_pre->size = 52; 
		$edit->usu_pre->maxlength = 50;
		$edit->usu_pre->group="Informaci&oacute;n de Usuario";
		$edit->usu_pre->append(' Se utiliza para recuperar su contra&ntilde;a');
				
		$edit->buttons("modify", "save","delete");
		$edit->build();
		
		$link=site_url('supervisor/usuarios/get_zonidm');
		$link2=site_url('supervisor/usuarios/get_zonidp');
		$link3=site_url('supervisor/usuarios/get_zonids');

		$data['script']  =<<<script
		<script type="text/javascript" charset="utf-8">
		function get_zonidm(){
			var zonide=$("#zon_ide").val();
			$.ajax({
				url: "$link"+'/'+zonide,
				success: function(msg){
					$("#td_zon_idm").html(msg);
				//alert(zonide); 
				}
			});			
		}
		function get_zonidp(){
			var zonidm=$("#zon_idm").val();
			$.ajax({
				url: "$link2"+'/'+zonidm,
				success: function(msg){
					$("#td_zon_idp").html(msg);
					//alert(zonidm);
				}
			});
		}
		function get_zonids(){
			var zonidp=$("#zon_idp").val();
			$.ajax({
				url: "$link3"+'/'+zonidp,
				success: function(msg){
					$("#td_zon_ids").html(msg);
					//alert(zonidp);
				}
			});
		}		
		
		</script>
script;
		//$smenu['link']=barra_menu('901');
		//$data['smenu']   = $this->load->view('view_sub_menu', $smenu,true);		
		$data['content'] =$edit->output;        
		$data['title'] = heading('('.$edit->usu_login->value.') '.$edit->usu_nom->value.' '.$edit->usu_ape->value);
		$data["head"]    = script("jquery.pack.js").script("plugins/jquery.numeric.pack.js").script("plugins/jquery.floatnumber.js").$this->rapyd->get_head();
		$data1['content']=$this->load->view('view_dataedit', $data,TRUE); 
        $this->load->view('view_fycotelecom', $data1);
    }
	function accesos($usr){
	
		$this->rapyd->load("datagrid2");
		
		$mSQL="SELECT a.men_cod as modulo,men_panel as panel,a.men_titulo as titulo,b.acceso  	
		FROM menu AS a                                                                 
		JOIN accesos AS b ON a.men_cod=b.men_cod
		WHERE usu_login='$usr'";
		
		$mc = $this->db->query($mSQL);
		
		$select=array('modulo','titulo', "IFNULL(b.acceso,'N') AS acceso",'panel');
		$tabla=form_open('accesos/guardar').form_hidden('usuario',$usr).'<div id=\'ContenedoresDeData\'><table width=100% cellspacing="0">';
		$i=0;
		$panel = '';
			
		foreach( $mc->result() as $row ){                                                                                                                                  
			if($row->acceso=='S') $row->acceso=TRUE; else $row->acceso=FALSE;	                                                                                                                                                            
			if(strlen($row->modulo)==1) {                                                                                                                              
				$tabla.= '<tr><th colspan=2>'.$row->panel.'</th></tr>';                                                                                      
				$panel = '';                                                                                                                                             
			}                                                                                                                                                   
				$tabla.= '<tr><td><b>&nbsp;&nbsp;-&nbsp;</b>'.$row->titulo.'</td><td>'.form_checkbox('accesos['.$i.']',$row->modulo,$row->acceso).'</td></tr>';
				$i++;                                                                                                                                                    
			}                                                                                                                                                          
                                                                                                                                                          
		
		$tabla.='</table></div>';
		$tabla.=form_hidden('usuario',$usr).form_submit('pasa','Guardar').form_close();
		
		$data['content'] = $tabla;
		$data['filtro']  = '';
		$data["head"]    = style('estilos.css');
		$data['title']   = heading("Accesos de Usuarios");
		$this->load->view('view_ventanas', $data);
	} 
	
    function _pos_insert2($do){
        
        $usuario=$do->get('usu_login');
        
        $mSQL=$this->db->query("UPDATE usuarios SET usu_status='A',usu_super='N',usu_fec=CURDATE(),usu_tip='C' WHERE usu_login='$usuario'");
        
    }
    function _pos_insert($do){
		$usuario=$do->get('usu_login');
		$nombre=$do->get('usu_nom');
		$tipo=$do->get('usu_tip');
		$benefi=$do->get('usu_benefi');
		$tusu_des=$this->datasis->dameval("SELECT tusu_des FROM tusuarios WHERE tusu_cod='$tipo'");
		if($benefi=='S'){
			$zona=$do->get('zon_cod');
			$sector=$do->get('sec_cod');
			$ape=$do->get('usu_ape');
			$sex=$do->get('usu_sex');
			$nac=$do->get('usu_nac');
			$ced=$do->get('usu_ced');
			$dir=$do->get('usu_dir');
			$tel=$do->get('usu_tel');
			$cel=$do->get('usu_cel');
			$correo=$do->get('usu_correo');
								
			$mSQL="INSERT IGNORE INTO pnatural(zon_cod,sec_cod,pnatu_nom,pnatu_ape,pnatu_sex,pnatu_nac,pnatu_ced,pnatu_dir,pnatu_tel,pnatu_cel,pnatu_correo)VALUE('$zona','$sector','$nombre','$ape','$sex','$nac','$ced','$dir','$tel','$cel','$correo')";
			$this->db->simple_query($mSQL);
			logusu('pnatural','REGISTRADO MOD USUARIOS',$usuario,$nombre,$ape);
			logusu('usuarios','REGISTRADO',$usuario,$nombre,$tusu_des);		
		}else{
			logusu('usuarios','REGISTRADO',$usuario,$nombre,$tusu_des);
		}	
		return TRUE;
	}	
	function _pos_update($do){
		$usuario=$do->get('usu_login');
		$nombre=$do->get('usu_nom');
		$tipo=$do->get('usu_tip');
		$benefi=$do->get('usu_benefi');
		$tusu_des=$this->datasis->dameval("SELECT tusu_des FROM tusuarios WHERE tusu_cod='$tipo'");
		if($benefi=='S'){
			$zona=$do->get('zon_cod');
			$sector=$do->get('sec_cod');
			$ape=$do->get('usu_ape');
			$sex=$do->get('usu_sex');
			$nac=$do->get('usu_nac');
			$ced=$do->get('usu_ced');
			$dir=$do->get('usu_dir');
			$tel=$do->get('usu_tel');
			$cel=$do->get('usu_cel');
			$correo=$do->get('usu_correo');
								
			$mSQL="INSERT IGNORE INTO pnatural(zon_cod,sec_cod,pnatu_nom,pnatu_ape,pnatu_sex,pnatu_nac,pnatu_ced,pnatu_dir,pnatu_tel,pnatu_cel,pnatu_correo)VALUE('$zona','$sector','$nombre','$ape','$sex','$nac','$ced','$dir','$tel','$cel','$correo')";
			$this->db->simple_query($mSQL);
			logusu('pnatural','REGISTRADO MOD USUARIOS',$usuario,$nombre,$ape);
			logusu('usuarios','MODIFICADO',$usuario,$nombre,$tusu_des);		
		}else{
			logusu('usuarios','MODIFICADO',$usuario,$nombre,$tusu_des);
		}	
		return TRUE;
	}
	function _pos_delete($do){
		$usuario=$do->get('usu_login');
		$nombre=$do->get('usu_nom');
		$tipo=$do->get('usu_tip');
		$tusu_des=$this->datasis->dameval("SELECT tusu_des FROM tusuarios WHERE tusu_cod='$tipo'");
		logusu('usuarios','ELIMINADO',$usuario,$nombre,$tusu_des);
		return TRUE;
	}
	function chexiste($codigo){
		$codigo=$this->input->post('usu_login');
		$chek=$this->datasis->dameval("SELECT COUNT(*) FROM usuarios WHERE usu_login='$codigo'");
		if ($chek > 0){
			$this->validation->set_message('chexiste',"Ya existe un usuario $codigo por favor ingrese otro nombre de usuario");
			return FALSE;
		}else {
  		return TRUE;
		}
	}
	function chexistecedula($cedula){
		$cedula=$this->input->post('usu_ced');
		$chek=$this->datasis->dameval("SELECT COUNT(*) FROM usuarios WHERE usu_ced='$cedula'");
		if ($chek > 0){
			$chek=$this->db->query("SELECT usu_nom,usu_ape FROM usuarios WHERE usu_ced='$cedula'");
			$row =    $chek->row();
			$nombre   =$row->usu_nom;
			$apellido  =$row->usu_ape;
			$this->validation->set_message('chexistecedula',"El usuario con cedula de indentidad $cedula ya esta ingresao en el sistema como $apellido $nombre");
			return FALSE;
		}else {
  		return TRUE;
		}
	}
	function chexistependientes($tipo){
		$tipo=$this->input->post('usu_tip');
		$login=$this->input->post('usu_login');
		$chek=$this->datasis->dameval("SELECT COUNT(*) FROM usuarios WHERE usu_login='$usu_login'");
		if ($chek > 0){
			$this->validation->set_message('chexistependientes',"El usuario tiene solicitudes pendientes no se puede procesar el cambio");
			return FALSE;
		}else {
			return TRUE;
		}
	}
	function clave($clave1,$clave2){
		$clave1=$this->input->post('usu_contra');
		$clave2=$this->input->post('usu_contra2');
		if($clave1<>$clave2){
			$this->validation->set_message('clave',"La contrase&ntilde;a y la confirmaci&oacute;n de clave no son iguales");
		}else {
			return true;
		}	
	}
}
?>
